﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;
using DBUlitity;
using System.Data;

namespace BLL
{
    public  class EquInfoBLL
    {

        public static string initEquTypeList()
        {
            string jsonStr = "[]";
            List<EquKaoHaoInfo> EquKaoHaoList = EquInfoDAL.initCustomerInfo();
            jsonStr = JSONTools.ScriptSerialize<List<EquKaoHaoInfo>>(EquKaoHaoList);
            return jsonStr;
        }

        public static string GetEquNoList(string EquType, string CustomerID)
        {
            string jsonStr = "[]";
            List<EquInfo> equList = EquInfoDAL.GetEquNoList(EquType,CustomerID);
            jsonStr = JSONTools.ScriptSerialize<List<EquInfo>>(equList);
            return jsonStr;
        }

        public static string addEquTypeInfo(string EquTypeName, string EquTypeRemark, string EquIndex)
        {
            string jsonStr = EquInfoDAL.addEquTypeInfo(EquTypeName, EquTypeRemark, EquIndex);
            return jsonStr;
        }

        /// <summary>
        /// 设置 纺纱品种
        /// </summary>
        /// <param name="TaiHao"></param>
        /// <param name="FangShaKind"></param>
        /// <param name="CustomerID"></param>
        /// <returns></returns>
        public static string savefangshakind(string TaiHao,string EquNo, string FangShaKind,  string FangShaDate, string CustomerID)
        {
            string jsonStr = EquInfoDAL.savefangshakind(TaiHao,EquNo, FangShaKind,FangShaDate, CustomerID);
            return jsonStr;
        }

        /// <summary>
        /// 设置 维护周期
        /// </summary>
        /// <param name="TaiHao"></param>
        /// <param name="MaintenanceCycle"></param>
        /// <param name="CustomerID"></param>
        /// <returns></returns>
        public static string saveMaintenanceCycle(string TaiHao,string EquNo,string MaintenanceCycle,string CustomerID)
        {
            string jsonStr = EquInfoDAL.saveMaintenanceCycle(TaiHao,EquNo, MaintenanceCycle, CustomerID);
            return jsonStr;
        }
        /// <summary>
        /// 设备维护操作
        /// </summary>
        /// <param name="TaiHao"></param>
        /// <param name="CustomerID"></param>
        /// <returns></returns>
        public static string maintenanceEquInfo(string TaiHao,string EquNo, string CustomerID)
        {
            string jsonStr = EquInfoDAL.maintenanceEquInfo(TaiHao, EquNo, CustomerID);
            return jsonStr;
        }

        public static string addEquKaoHao(string EquNo, string EquType, string Remark)
        {
            string jsonStr = EquInfoDAL.addEquKaoHao(EquNo, EquType, Remark);
            return jsonStr;
        }

        /// <summary>
        /// 初始化设备类型列表
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="keyvalue"></param>
        /// <param name="EquIndex"></param>
        /// <returns></returns>
        public static DataTable GetEquTypeInfo(string sidx, string sord, string keyvalue, string EquIndex)
        {
            DataTable dt = new DataTable();
            dt = EquInfoDAL.GetEquTypeInfo(sidx, sord, keyvalue, EquIndex);
            return dt;
        }

        /// <summary>
        /// 初始化设备故障信息 列表
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="keyvalue"></param>
        /// <returns></returns>
        public static DataTable GetEquAlarmInfo(string sidx, string sord, string keyvalue)
        {
            DataTable dt = new DataTable();
            dt = EquInfoDAL.GetEquAlarmInfo(sidx, sord, keyvalue);
            return dt;
        }
        /// <summary>
        /// 当是  宏大用户登录  获取设备列表信息
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="keyvalue"></param>
        /// <returns></returns>
        public static DataTable initEquListByHongda(string sidx, string sord, string keyvalue, string CustomerName)
        {
            DataTable dt = new DataTable();
            dt = EquInfoDAL.initEquListByHongda(sidx, sord, keyvalue, CustomerName);
            return dt;
        }

        /// <summary>
        /// 当是 客户登录 获取所购设备列表
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="keyvalue"></param>
        /// <param name="CustomerName"></param>
        /// <returns></returns>
        public static DataTable initEquListByCustomerID(string sidx, string sord, string keyvalue, string CustomerName)
        {
            DataTable dt = new DataTable();
            dt = EquInfoDAL.initEquListByCustomerID(sidx, sord, keyvalue, CustomerName);
            return dt;
        }

        /// <summary>
        /// 删除设备类信息
        /// </summary>
        /// <param name="TypeID"></param>
        /// <returns></returns>
        public static string deleteEquTypeInfo(string TypeID, string FeatureID)
        {
            int t = EquInfoDAL.deleteEquTypeInfo(TypeID,FeatureID);
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }

        /// <summary>
        /// 删除设备信息
        /// </summary>
        /// <param name="EquID"></param>
        /// <returns></returns>
        public static string deleteEquInfo(string EquID)
        {
            int t = EquInfoDAL.deleteEquInfo(EquID);
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }
        public static string deleteEquTypeInfoguidao(string EquID)
        {
            int t = EquInfoDAL.deleteEquTypeInfoguidao(EquID);
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }
        /// <summary>
        /// 编辑设备类型初始化界面
        /// </summary>
        /// <param name="TypeID"></param>
        /// <returns></returns>
        public static string initeditequtype(string TypeID, string FeatureID)
        {
            string jsonStr = "[]";
            List<EquKaoHaoInfo> customerList = EquInfoDAL.initeditequtype(TypeID,FeatureID);
            jsonStr = JSONTools.ScriptSerialize<List<EquKaoHaoInfo>>(customerList);
            return jsonStr;
        }

        /// <summary>
        /// 初始化设备报警编辑界面
        /// </summary>
        /// <param name="AlarmID"></param>
        /// <returns></returns>
        public static string initeditequalarm(string AlarmID)
        {
            string jsonStr = "[]";
            List<ShengchanCushaAlarm> customerList = EquInfoDAL.initeditequalarm(AlarmID);
            jsonStr = JSONTools.ScriptSerialize<List<ShengchanCushaAlarm>>(customerList);
            return jsonStr;
        }


        /// <summary>
        /// 保存编辑设备类型
        /// </summary>
        /// <param name="TypeID"></param>
        /// <param name="EquTypeName"></param>
        /// <param name="EquTypeRemark"></param>
        /// <param name="EquIndex"></param>
        /// <returns></returns>
        public static string editequtype(string TypeID,string FeatureID, string EquTypeName, string EquTypeRemark, string EquIndex, string EquTypeFeatures, string FeaturesContent, string MaintenanceCycle, string ChangeEquNo)
        {
            string jsonStr = EquInfoDAL.editequtype(TypeID,FeatureID, EquTypeName, EquTypeRemark, EquIndex, EquTypeFeatures, FeaturesContent, MaintenanceCycle, ChangeEquNo);
            return jsonStr;
        }

        public static string editequtypeguidao(string TypeID, string EquTypeName, string EquTypeRemark, string EquIndex)
        {
            string jsonStr = EquInfoDAL.editequtypeguidao(TypeID,  EquTypeName, EquTypeRemark, EquIndex);
            return jsonStr;
        }
        /// <summary>
        /// 保存设备类型特性
        /// </summary>
        /// <param name="EquTypeFeatures"></param>
        /// <param name="FeaturesContent"></param>
        /// <param name="MaintenanceCycle"></param>
        /// <returns></returns>
        public static string saveEquTypeFeature(string EquTypeFeatures, string FeaturesContent, string MaintenanceCycle)
        {
            string jsonStr = EquInfoDAL.saveEquTypeFeature(EquTypeFeatures, FeaturesContent, MaintenanceCycle);
            return jsonStr;
        }

        /// <summary>
        /// 得到设备类型特性列表
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="EquTypeName"></param>
        /// <returns></returns>
        public static DataTable getEquTypeFeatureList(string sidx, string sord, string EquTypeName)
        {
            DataTable dt = new DataTable();
            dt = EquInfoDAL.getEquTypeFeatureList(sidx, sord, EquTypeName);
            return dt;
        }

        /// <summary>
        /// 编辑设备类型特性初始化界面
        /// </summary>
        /// <param name="FeatureID"></param>
        /// <returns></returns>
        public static string initEquTypeFeaterEditForm(string FeatureID)
        {
            string jsonStr = "[]";
            List<EquTypeFeaturesInfo> EquTypeFeatures = EquInfoDAL.initEquTypeFeaterEditForm(FeatureID);
            jsonStr = JSONTools.ScriptSerialize<List<EquTypeFeaturesInfo>>(EquTypeFeatures);
            return jsonStr;
        }

        /// <summary>
        /// 保存编辑设备类型特性
        /// </summary>
        /// <param name="FeatureID"></param>
        /// <param name="EquTypeFeatures"></param>
        /// <param name="FeaturesContent"></param>
        /// <param name="MaintenanceCycle"></param>
        /// <returns></returns>
        public static string editEquTypeFeature(string FeatureID, string EquTypeFeatures, string FeaturesContent, string MaintenanceCycle)
        {
            string jsonStr = EquInfoDAL.editEquTypeFeature(FeatureID, EquTypeFeatures, FeaturesContent, MaintenanceCycle);
            return jsonStr;
        }

        /// <summary>
        /// 新增设备类型界面  如果点击关闭按钮  就删除未分配到设备类型的特性
        /// </summary>
        /// <returns></returns>
        public static string deleteuntypefeature()
        {
            int t = EquInfoDAL.deleteuntypefeature();
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }

        /// <summary>
        /// 保存新增设备类型   带有设备类型特性
        /// </summary>
        /// <param name="EquTypeName"></param>
        /// <param name="EquTypeRemark"></param>
        /// <param name="EquIndex"></param>
        /// <param name="EquTypeTexingID"></param>
        /// <returns></returns>
        public static string saveEquTypeWithTexing(string EquTypeName, string EquTypeRemark, string EquIndex, List<string> EquTypeTexingID)
        {
            string jsonStr = EquInfoDAL.saveEquTypeWithTexing(EquTypeName, EquTypeRemark,EquIndex, EquTypeTexingID);
            return jsonStr;
        }

        /// <summary>
        /// 保存  编辑设备信息
        /// </summary>
        /// <param name="EquNo"></param>
        /// <param name="Remark"></param>
        /// <returns></returns>
        public static string saveeditequ(string EquNo, string EquNewNo, string Remark)
        {
            string jsonStr = EquInfoDAL.saveeditequ(EquNo,EquNewNo, Remark);
            return jsonStr;
        }

        /// <summary>
        /// 保存  编辑设备故障信息
        /// </summary>
        /// <param name="AlarmID"></param>
        /// <param name="AlarmName"></param>
        /// <param name="AlarmHandle"></param>
        /// <param name="note"></param>
        /// <returns></returns>
        public static string saveeditequalarm(string AlarmID, string AlarmName, string AlarmHandle, string note)
        {
            string jsonStr = EquInfoDAL.saveeditequalarm(AlarmID, AlarmName, AlarmHandle, note);
            return jsonStr;
        }

        public static string initfangshabyid(string FangshaID)
        {
            return JSONTools.ScriptSerialize<List<CustomerEquFangShaKind>>(EquInfoDAL.initfangshabyid(FangshaID));
        }

        public static string saveShengChanfangshakind(string FangShaKind, string CustomerID, string OutPutTarget, string FangShaDate)
        {
            return EquInfoDAL.saveShengChanfangshakind(FangShaKind, CustomerID, OutPutTarget, FangShaDate);
        }

        public static string editShengChanfangshakind(string FangShaKind, string OutPutTarget, string FangShaDate, string ID)
        {
            return EquInfoDAL.editShengChanfangshakind(FangShaKind, OutPutTarget, FangShaDate, ID);
        }


        public static string initShengChanSetInfo(string CustomerID)
        {
            return JSONTools.ScriptSerialize<List<CustomerEquFangShaKind>>(EquInfoDAL.initShengChanSetInfo(CustomerID));
        }

 


    }
}
